//
//  ViewModelIndexPosition.h
//  Chart
//
//  Created by CaoJun on 15/1/14.
//
//

#ifndef __Chart__ViewModelIndexPosition__
#define __Chart__ViewModelIndexPosition__

#include "Quotation.h"
#include "KLineData.h"
#include "AVGData.h"
#include "Rectangle.h"


namespace ytx {
    
    class ViewModelIndexPosition{
    protected:
        int startDataIndex;
        int endDataIndex;
        int changeStep;
        
        int minShowViewCount;
        int maxShowViewCount;
        int showViewCount;
        
        Rectangle rect;
        
        Quotation * data;
        
        int originShowViewCount;
        float originScale;
        
    public:
        IndexType::IndexType indexType;
        int totalDataCount;
        ViewModelIndexPosition();
        ViewModelIndexPosition(int minShowViewCount, int maxShowViewCount);
        
        void initViewIndexByDataIndexAndRect(int showViewCount);
        void initViewIndexByDataIndexAndRect(Quotation * data);
        void initViewIndexByDataIndexAndRect(Quotation * data, int showViewCount);
        void initViewIndexByDataIndexAndRect(Quotation * data, int showViewCount, int minShowViewCount, int maxShowViewCount);
        void initViewIndexByDataIndexAndRect(Quotation * data, Rectangle rect, int showViewCount, int minShowViewCount, int maxShowViewCount);
        
        int fixShowViewCount(int showViewCount);
        int fixStartDataIndexDrag(int startDataIndex);
        int fixStartDataIndex(int startDataIndex);
        int fixEndDataIndex(int endDataIndex);
        
        void setRectangle(Rectangle rect);
        
        Rectangle& getRectangle();
        
        void setShowViewCount(int showViewCount);
        
        bool isTheLastDataIndex();
        
        bool concatCount(Quotation * data);
        
        void setTotalDataCount(int totalDataCount);
        
        void zoom(int step);
        
        void drag(int step);
        
        int getDataIndexByPX(float x);
        
        int getViewIndexByPX(float x);
        
        int getViewIndexByDataIndex(int index);
        
        int getViewPxByDataIndexWithoutModify(int index);
        
        float getViewPxByDataIndex(int index);
        
        float getViewPxByViewIndex(int index);
        
        int getStartDataIndex();
        
        int getEndDataIndex();
        
        int getEndDataIndexInRange();
        
        int getShowViewCount();
        
        bool hadInited();
        
        void zoomByScaleBegin(float scale);
        
        void zoomByScale(float scale);
        
        void setPara(Quotation * data);
        
        void resetPara();
        
        bool isRightEmpty();
        bool hjjtGJPermission();
        Quotation * getData();
        
        //        void setStartIndex(unsigned int);
        //        void setEndIndex(unsigned int);
        //        void locationWithShowCountAndEndIndex(unsigned int totalCount, unsigned int showCount, unsigned int endIndex);
        //
        //        const unsigned int getShowCount();
        //        const unsigned int getStartIndex();
        //        const unsigned int getEndIndex();
        //
        //        const unsigned int getTotalDataCount();
        //
        //        const unsigned int getDataIndexByViewIndex(unsigned int viewIndex);
        //
        //        const unsigned int getViewStartIndex();
        //
        //        const unsigned int getViewEndIndex();
        //        
        //        bool isTheLastDataIndex();
        
    };
    
}

#endif /* defined(__Chart__ViewModelIndexPosition__) */
